<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<title></title>
	<script type="text/javascript" src="../../js/boot.js"></script>
	<script type="text/javascript" src="../../js/lib/json3.min.js"></script>
</head>

<body>
	<div class="mini-tabs" activeIndex="0" style="width:100%;height:100%;">

		<div title="工作">
			<div style="width:99%;height:99%;">
				<div style="float:left; width:35%; height:100%;">
					<fieldset style="width: 100%;height:100%;">
						<legend><span>工时分项</span></legend>
						<div class="mini-fit">
							<ul id="sortTree" class="mini-tree" showCheckBox="true" style="width:240px;" showTreeIcon="true" allowDrag="true" allowDrop="true"
								textField="sortName" idField="projectSortID" resultAsTree="false">
							</ul>
						</div>
					</fieldset>
				</div>
				<div style="float:right; width:65%; height:100%;">
					<fieldset style="width: 100%;height:100%;">
						<legend><span>工作内容</span></legend>
						<div class="mini-fit">
							<div id="detailForm" style="padding:10px;">
								<table align="center">
									<tr>
										<td align="right">项目名称：</td>
										<td align="left"><input id="projectID" name="projectID" class="mini-combobox" textField="projectName"
												valueField="projectID"></td>
										<td align="right">工作时长：</td>
										<td align="left"><input name="workTime" class="mini-spinner" increment="0.5" minValue="0" maxValue="12"></td>
									</tr>
									<tr>
										<td align="right">工作包主名称：</td>
										<td align="left"><input id="projectMainPacketID" class="mini-combobox" textField="packetName"
												valueField="projectPacketID"></td>
										<td align="right">工作包子名称：</td>
										<td align="left"><input id="projectPacketID" name="projectPacketID" class="mini-combobox" textField="packetName"
												valueField="projectPacketID"></td>
									</tr>
									<tr>
										<td align="right">图纸名称：</td>
										<td align="left" colspan="3"><input id="projectDrawID" name="projectDrawID" class="mini-autocomplete"
												textField="drawName" valueField="projectDrawID" width="400"></td>
									</tr>
									<tr>
										<td align="right">工作说明：</td>
										<td align="left" colspan="3"><textarea name="description" class="mini-textarea" width="400"></textarea></td>
									</tr>
								</table>
							</div>
							<div property="footer" style="text-align:center;padding:5px;padding-right:15px;">
								<a class="mini-button" iconCls="icon-save" onClick="doSaveConfig()">保存</a>
								<a class="mini-button" iconCls="icon-cancel" onClick="cancel()">取消</a>
							</div>
						</div>
					</fieldset>
				</div>
			</div>
		</div>

		<div title="图纸">
			<fieldset id="fd1" style="width: 97%; margin-bottom: 10px;">
				<legend><span>查询条件</span></legend>
				<div id="queryForm" class="fieldset-body">
					<table class="form-table" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<td class="form-label">
								<span>图纸名称：</span>
								<input name="drawName" class="mini-textbox" style="width: 150px" />
								<input name="drawName_link" value="like" class="mini-hidden" style="width: 150px" />
								<a style="margin: 0 0 0 0;" class="mini-button" iconCls="icon-search" onclick="doSearch()">查询</a>
							</td>
						</tr>
					</table>
				</div>
			</fieldset>
			<div class="mini-fit">
				<div id="drawDatagrid" class="mini-datagrid" style="width:99%;height:95%;" allowCellEdit="true" allowCellSelect="true" showPager="false">
					<div property="columns">
						<div field="index" type="indexcolumn" width="30"></div>
						<div name="projectName" field="projectName" headerAlign="center" width="40">项目名称</div>
						<div name="drawName" field="drawName" headerAlign="center" width="80">图纸名称</div>
						<div name="workTime" field="workTime" headerAlign="center" width="40">工作时长
							<input property="editor" class="mini-spinner" increment=0.5 style="width:100%;" minWidth="40" />
						</div>
						<div name="hasWorkedRate" field="hasWorkedRate" headerAlign="center" width="40">完成进度
							<input property="editor" class="mini-combobox" textField="text" valueField="id" data="workedRate" style="width:100%;"
								minWidth="40" />
						</div>
						<div name="description" field="description" headerAlign="center" width="80">工作说明
							<input property="editor" class="mini-textbox" increment="0.5" style="width:100%;" minWidth="160" />
						</div>
						<div name="sequence" headerAlign="center" width="60">排序</div>
					</div>
				</div>
			</div>
		</div>

		<div title="基本">
			<div id="dayForm" style="padding:10px;">
				<input name="dayReportID" class="mini-hidden" enabled="false">
				<table align="center">
					<tr>
						<td align="right">用户姓名：</td>
						<td align="left"><input name="userName" class="mini-textbox" enabled="false"></td>
						<td align="right">部门名称：</td>
						<td align="left"><input name="departName" class="mini-textbox" enabled="false"></td>
						<td align="right">日期：</td>
						<td align="left"><input name="calendarDate" class="mini-textbox" enabled="false"></td>
					</tr>
					<tr>
						<td align="right">日期类型：</td>
						<td align="left"><input name="dayType" class="mini-textbox" enabled="false"></td>
						<td align="right">刷卡记录：</td>
						<td align="left" colspan="3"><input name="cardRecord" class="mini-textbox" width="400" enabled="false"></td>
					</tr>
					<tr>
						<td align="right">排班上班时间：</td>
						<td align="left"><input name="startWorkTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
						<td align="right">排班下班时间：</td>
						<td align="left" colspan="3"><input name="endWorkTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
					</tr>
					<tr>
						<td align="right">实际上班时间：</td>
						<td align="left"><input name="recordStartWorkTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
						<td align="right">实际下班时间：</td>
						<td align="left" colspan="3"><input name="recordEndWorkTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
					</tr>
					<tr>
						<td align="right">工作时长：</td>
						<td align="left"><input id="workTime" name="workTime" class="mini-spinner" increment="0.5" minValue="0"></td>
						<td align="right">加班时长：</td>
						<td align="left"><input id="overTime" name="overTime" class="mini-spinner" increment="0.5" minValue="0"></td>
						<td align="right">请假时长：</td>
						<td align="left"><input id="applyTime" name="applyTime" class="mini-spinner" increment="0.5" minValue="0"></td>
					</tr>
					<tr>
						<td align="right">提交时间：</td>
						<td align="left"><input name="submitTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
						<td align="right">提交备注：</td>
						<td align="left" colspan="3"><input id="submitRemark" name="submitRemark" class="mini-textbox" width="400"></td>
					</tr>
					<tr>
						<td align="right">审核时间：</td>
						<td align="left"><input name="checkedTime" class="mini-datepicker" format="yyyy-MM-dd HH:mm" enabled="false"></td>
						<td align="right">审核备注：</td>
						<td align="left" colspan="3"><input id="checkRemark" name="checkRemark" class="mini-textbox" width="400"></td>
					</tr>
				</table>
			</div>
			<div style="text-align:center;padding:5px;padding-right:15px;">
				<a class="mini-button" iconCls="icon-save" id="doSave" onClick="doSave()">保存</a>
				<a class="mini-button" iconCls="icon-save" id="doSubmit" onClick="doSubmit()">提交</a>
				<a class="mini-button" iconCls="icon-ok" id="doPass" onClick="doPass()">通过</a>
				<a class="mini-button" iconCls="icon-remove" id="doReject" onClick="doReject()">不通过</a>
			</div>
		</div>

	</div>

</body>

<script type="text/javascript">
	var localUser = null;
	var userID = null;
	var obj = localStorage.getItem('user');
	if (obj) {
		localUser = mini.decode(obj);
		userID = localUser.userID;
	}

	// 工作进度
	var workedRate = [
		{ id: 0.1, text: "10%" },
		{ id: 0.2, text: "20%" },
		{ id: 0.3, text: "30%" },
		{ id: 0.4, text: "40%" },
		{ id: 0.5, text: "50%" },
		{ id: 0.6, text: "60%" },
		{ id: 0.7, text: "70%" },
		{ id: 0.8, text: "80%" },
		{ id: 0.9, text: "90%" },
		{ id: 1, text: "100%" }
	];

	miniInit();

	var sortTree = mini.get("sortTree");
	http.get("/oa/project/sort/list.do", function (page) {
		if (page.data.length > 0) {
			sortTree.loadList(page.data, "projectSortID", "parentID");
			// var node = sortTree.getNode("ROOT000200010001");
			// sortTree.expandPath(node);
		} else {
			sortTree.addNode({
				projectSortID: "ROOT",
				sortName: "公司"
			}, 0, null);
		}
	});

	// 项目名称控件数据
	var projectCombox = mini.get("projectID");
	var projectUrl = "/oa/project/project/list.do?tstatus=1";
	if (userID != null) {
		projectUrl = projectUrl + "&userID=" + userID;
	}
	http.get(projectUrl, function (page) {
		if (page.data.length > 0) {
			projectCombox.setData(page.data);
		}
	});

	// 图纸控件数据
	var projectDrawIDComBox = mini.get("projectDrawID");
	var projectDrawIDUrl = "/project/draw/page.do";
	if (userID != null) {
		projectDrawIDUrl = projectDrawIDUrl + "?userID=" + userID;
	}
	projectDrawIDComBox.set({
		url: http.getUrl(projectDrawIDUrl)
	});

	// 工作包主名称
	var projectMainPacketIDComBox = mini.get("projectMainPacketID");
	projectMainPacketIDComBox.set({
		url: http.getUrl("/oa/project/packet/list.do?parentID=ROOT")
	});
	// 工作包子名称
	var projectPacketIDComBox = mini.get("projectPacketID");
	var projectPacketIDUrl = "/oa/project/packet/list.do?parentID=";
	if (projectPacketIDComBox.getValue() != "") {
		http.get(projectPacketIDUrl + projectMainPacketIDComBox.getValue(), function (page) {
			if (page.data.length > 0) {
				projectPacketIDComBox.setData(page.data);
			}
		});
	}
	// 主目录切换，子目录同步变更
	projectMainPacketIDComBox.on("valuechanged", function (e) {
		http.get(projectPacketIDUrl + e.value, function (page) {
			if (page.data.length > 0) {
				projectPacketIDComBox.setData(page.data);
			}
		});
	});

	var drawDatagrid = mini.get("drawDatagrid"); // 工作日报的子项数据表格
	drawDatagrid.on("drawcell", function (e) {
		var record = e.record,
			column = e.column,
			field = e.field,
			value = e.value;
		//action列，超连接操作按钮
		if (e.column.name == "sequence") {
			e.cellStyle = "text-align:center";
			e.cellHtml = '<a href="javascript:fieldGridMoveRow(\'' + record._uid + '\', -1)">上移</a>&nbsp; ' +
				'<a href="javascript:fieldGridMoveRow(\'' + record._uid + '\', 2)">下移</a>';
		}
	});

	var dayWorkData = {}; // 分时分项工作数据，是Map类数据，主键是projectSortID工时分项编号
	var dayForm = new mini.Form("#dayForm"); // 日报属性页

	function initial() {
		if (localUser == null) {
			alert("你还没有登录，请先登录再操作...");
			return;
		}
		http.get("/user/get.do?userID=" + localUser.userID, function (page) {
			var data = page.data.config;
			if (data && data.length > 0) {
				var config = JSON.parse(data);
				var sort = config.sort;
				if (sort != null && sort.length > 0) {
					for (var i = 0; i < sort.length; i++) {
						// 把已编辑的节点展开
						var node = sortTree.getNode(sort[i]);
						sortTree.expandNode(node);
					}
				}
				// 项目名称
				if (config.projectID) {
					projectCombox.setValue(config.projectID);
				}
				// 工作包主名称
				if (config.projectMainPacketID) {
					projectMainPacketIDComBox.setValue(config.projectMainPacketID);
					http.get(projectPacketIDUrl + config.projectMainPacketID, function (page) {
						if (page.data.length > 0) {
							projectPacketIDComBox.setData(page.data);
						}
					});
				}
				// 工作包子名称
				if (config.projectPacketID) {
					projectPacketIDComBox.setValue(config.projectPacketID);
				}
			}
		});
	}

	function doSaveConfig() {
		var localUser = mini.decode(localStorage.getItem('user'));
		if (localUser == null) {
			alert("你还没有登录，请先登录再操作...");
			return;
		}
		var config = {
			sort: [],
			projectID: null,
			projectMainPacketID: null,
			projectPacketID: null
		};
		var nodes = sortTree.getList();
		for (var i = 0; i < nodes.length; i++) {
			if (sortTree.isExpandedNode(nodes[i])) {
				config.sort.push(nodes[i].projectSortID);
			}
		}
		var text = projectCombox.getValue();
		if (text && text.length > 0) {
			config.projectID = text;
		}
		text = projectMainPacketIDComBox.getValue();
		if (text && text.length > 0) {
			config.projectMainPacketID = text;
		}
		text = projectPacketIDComBox.getValue();
		if (text && text.length > 0) {
			config.projectPacketID = text;
		}

		var params = {
			userID: localUser.userID,
			config: JSON.stringify(config)
		};
		http.post("/user/saveUser.do", params, function (page) {
			if (page.success) {
				closeWindow("ok");
			} else {
				alert(page.Message);
			}
		});
	}

	function closeWindow(action) {
		if (window.CloseOwnerWindow)
			return window.CloseOwnerWindow(action);
		else
			window.close();
	}
</script>

</html>